/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agenda.model;

import com.agenda.model.entity.AmTbAgenMedi;
import com.agenda.model.entity.AmTbConvMedi;
import com.agenda.model.persistence.DAOFactory;
import com.agenda.model.repository.ConvenioMedicoRepository;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Ronildo
 */

@Stateless
@WebService(serviceName = "ConvenioMedicoBOImpl")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
public class ConvenioMedicoBOImpl {
    
    @PersistenceContext
    private EntityManager em;
    private ConvenioMedicoRepository convenioMedicoRepository;
    
    @PostConstruct
    public void initialize(){
        convenioMedicoRepository = DAOFactory.getConvenioMedicoRepository(em);
    }
    
    @WebMethod
    public void insertConvenioMedico(@WebParam(name = "convenioMedico")AmTbConvMedi convenioMedico){
        convenioMedicoRepository.persist(convenioMedico); 
    }
    
    @WebMethod
    public void deleteConvenioMedico(@WebParam(name = "convenioMedico")AmTbConvMedi convenioMedico){
        convenioMedicoRepository.remove(convenioMedico, new Long(convenioMedico.getCdConvMedi())); 
    }
    
    @WebMethod
    public void updateConvenioMedico(@WebParam(name = "convenioMedico")AmTbConvMedi convenioMedico){
        convenioMedicoRepository.update(convenioMedico); 
    }
    
    @WebMethod
    public AmTbConvMedi findConvenioMedicoById(@WebParam(name = "id")Long id){
        return convenioMedicoRepository.findById(id);
    }
    
    @WebMethod
    public List<AmTbConvMedi> listConvenioMedico(@WebParam(name = "convenioMedico")AmTbConvMedi convenioMedico){
        return convenioMedicoRepository.list(convenioMedico); 
    }
}
